(message "foo")

(defun simplified-end-of-buffer ()
  "Go to end of file before Mark current position."
  (interactive)
  (push-mark)
  (goto-char (point-max))
  )

(if (get-buffer "*emacs.txt")
    (message "exists")
  (message "not exists")
  )

(progn
  (defvar add3 (lambda (x) (+ x 3)))
  (funcall add3 4)
  )

(mapcar (lambda (x) (+ x 3))  '(1 2 3 4 5))

;; #' would turn symbol to variable
(mapcar #'log10 '(1 10 100 1000))

;; &rest collect all rest arguments into a list
(defun sum (&rest numbers)
  (apply #'+ numbers))

(defun make-shell-interface (&rest params)
  "
  Create a shell interface.

  Possible parameters:

    :name      Name of shell
    :type      ['sh, 'bash, ...]
    :path      Path to program
    :buffer    Name of buffer

  "
  (let
      ((name   (plist-get params :name ))
       (type   (plist-get params :type))
       (path   (plist-get params :path))
       (buffer (plist-get params :buffer)))
    (list
     (cons 'name buffer)
     (cons 'type type)
     (cons 'path path)
     (cons 'buffer buffer))))

(make-shell-interface :name "pylaucher" :path "/usr/bin/python" :type 'sh :buffer "pyshell")

;; use back tick to define macro
(defmacro make-sum-fun (f1 f2)
  `(lambda (x) (+ (,f1 x) (,f2 x))))

(progn
  (setq ll '(349 4930 203920))
  (nth 2 ll)
  (car (last ll)) 
  )

;; dictionary
(progn
  (setq dict
	'((pine . cones)
	  (oak . acorns)
	  (maple . seeds)))

  (cdr (assoc 'oak dict))
  (mapcar #'car dict)
  (mapcar #'cdr dict)
  )

(progn
  (defvar language-list
    '(
      ("io" . ((:command . "io")
	       (:description . "Run IO Language script")))
      ("lua" . ((:command . "lua")
		(:description . "Run Lua script")))
      ("groovy" . ((:command . "groovy")
		   (:description . "Run Groovy")))
      ("scala" . ((:command . "scala")
		  (:cmdopt . "-Dfile.encoding=UTF-8")
		  (:description . "Run Scala file with scala command")))

      ("haml" . ((:command . "haml")
		 (:exec    . "%c %o %s")
		 (:description . "Convert HAML to HTML")))
      ("sass" . ((:command . "sass")
		 (:exec    . "%c %o --no-cac")))
      ))
  (defun get-val (type key)
    (cdr (assoc key (assoc  type  language-list )))
    )
  (get-val "lua" ':description)
  )

(format-time-string "%Y%m%d%H%M%S" (current-time))
